<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex,nofollow" />
    <title>思客多商城管理系统</title>
    <meta name="generator" content="思客多" />
    <meta name="author" content="思客多" />
    <link href="{__FRAME_PATH}css/bootstrap.min.css?v=3.4.0" rel="stylesheet">
    <link href="{__PLUG_PATH}layui/css/layui.css" rel="stylesheet">
    <link href="{__FRAME_PATH}css/font-awesome.min.css?v=4.3.0" rel="stylesheet">
    <link href="{__FRAME_PATH}css/animate.min.css" rel="stylesheet">
    <link href="{__FRAME_PATH}css/style.min.css?v=3.0.0" rel="stylesheet">
    <script>
        top != window && (top.location.href = location.href);
    </script>
    <style>
        .login-group {
            margin-top: 20vh;
            background-color: #00111C;
            padding: 0 20px 20px;
            color: #111123;
            opacity: 0.8;
            border-radius: 7px;
            box-shadow: 0 0 10px #3FBEEB;
            border: 1px solid #74B5C9;
        }
        .login-logo p {
            color: #fff;
            font-size: 20px;
            font-weight: bolder;
            margin: 20px;
        }
    </style>
</head>
<body class="gray-bg login-bg">
<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div class="login-group">
        <h3 class="login-logo">
          <p>商户注册</p>
        </h3>
        <form role="form" onsubmit="return false">
            <div class="form-group" >
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-street-view"></i> </span>
                    <input type="text" id="real_name" name="real_name"  placeholder="用户姓名" class="form-control">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-user"></i> </span>
                    <input type="number" id="account" name="account" placeholder="手机号码"  class="form-control">
                </div>
            </div>
            <div class="form-group" >
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-home"></i> </span>
                    <select id="province" class="form-control" style="width: 50%">
                        <option value="0">请选择省</option>
                        {foreach $cities as $k=>$v}
                        <option value="{$v['city_id']}">{$v['merger_name']}</option>
                        {/foreach}
                    </select>
                    <select id="city" class="form-control" style="width: 50%">
                        <option value="0">请选择市</option>

                    </select>
                </div>
            </div>
            <div class="form-group" >
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-car"></i> </span>
                    <input type="text" id="company_name" name="company_name" placeholder="用户公司" class="form-control">
                </div>
            </div>

            <div class="form-group">
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-unlock-alt"></i> </span>
                    <input type="password" class="form-control" id="pwd" name="pwd" placeholder="密码">
                </div>
            </div>
            <div class="form-group">
                <div class="input-group m-b"><span class="input-group-addon"><i class="fa fa-trophy"></i> </span>
                    <input type="text" class="form-control" id="invite_code" name="invite_code" placeholder="邀请码（必填）" >
                </div>
            </div>
            <div class="form-group">
                <div class="input-group">
                    <input style="width: 60%" type="text" class="form-control" id="verify" name="verify" placeholder="验证码" >
                    <input style="height: 34px" type="button" id="getcode" value="发送验证码" onclick="daojishi(60)">
                </div>
            </div>
            <button class="btn btn-primary block full-width m-b" onclick="do_register()">注册</button>
            <p class="text-muted text-center"> <a href="{:url('login/index')}"><span style="color: #fffdf9">返回登陆</span></a></p>
        </form>
    </div>
</div>
<div class="footer" style=" position: fixed;bottom: 0;width: 100%;left: 0;margin: 0;opacity: 0.8;">
    <div class="pull-right">© 2017-2020 <a href="http://www.sifenxiao.cn" target="_blank">成都思软科技</a>
    </div>
</div>

<!-- 全局js -->
<script src="{__PLUG_PATH}jquery-1.10.2.min.js"></script>
<script src="{__FRAME_PATH}js/bootstrap.min.js?v=3.4.0"></script>
<!--<script src="{__MODULE_PATH}login/flaotfont.js"></script>-->
<script src="{__MODULE_PATH}login/ios-parallax.js"></script>
<script src="{__PLUG_PATH}layui/layui.all.js"></script>
<!--统计代码，可删除-->
<!--点击刷新验证码-->
<script>
    function daojishi(t) {
        var account = $('#account').val();
        if (!account) return layer.msg('请输入手机号码');
        if(account.length!=11){
            return layer.msg('手机号码有误');
        }
        var url = "{:url('send_msg')}";
        $.ajax({
            url: url,
            data: {
                account: account,
            },
            type: 'post',
            dataType: 'json',
            success: function (rem) {
                if (rem.code == 200 || rem.status == 200) {
                    layer.msg(rem.msg);
                    var intv = setInterval( function(){
                        t--;
                        if( t > 0 )
                        {
                            $("#getcode").attr('disabled', 'disabled');
                            $("#getcode").val( t +'秒获取');
                        }
                        else
                        {
                            $("#getcode").attr('disabled', false );
                            $("#getcode").val( '获取验证码');
                            clearInterval(intv);
                        }
                    }, 1000);
                } else {
                    layer.msg(rem.msg);
                    return false;
                }
            },
            error: function (err) {
                layer.msg('系统错误');
                return false;
            }
        });
    }
    function do_register() {
       var real_name = $('#real_name').val(), invite_code  = $('#invite_code').val();
       var city_name = $('#city').val(), company_name = $('#company_name').val();
       var account = $('#account').val(), pwd = $('#pwd').val(), verify = $('#verify').val();
       if (!real_name) return layer.msg('请输入用户姓名');
       if (!account) return layer.msg('请输入手机号码');
       if (!city_name) return layer.msg('请选择地区');
       if (city_name=='0') return layer.msg('请选择地区');
       if (!company_name) return layer.msg('请输入公司名称');
       if(account.length!=11){
           return layer.msg('手机号码有误');
       }
       if (!pwd) return layer.msg('请输入登陆密码');
       if (!verify) return layer.msg('请输入验证码');
       if (!invite_code) return layer.msg('请输入邀请码');
       var url = "{:url('do_register')}";
       $.ajax({
           url: url,
           data: {
               real_name: real_name,
               invite_code: invite_code,
               account: account,
               pwd: pwd,
               verify: verify,
               company_name:company_name,
               city_name:city_name
           },
           type: 'post',
           dataType: 'json',
           success: function (rem) {
               if (rem.code == 200 || rem.status == 200) {
                   layer.msg(rem.msg);
                   setTimeout(function () {
                       window.location.href = rem.data.url;
                   },1000)
               } else {
                   layer.msg(rem.msg);
               }
           },
           error: function (err) {
               layer.msg('系统错误');
           }
       });
        return false;
   }
    $("#province").change(function(){
        var url = "{:url('get_city')}";
        var parent_id = $('#province').val();
        $.ajax({
            url: url,
            data: {
                parent_id: parent_id,
            },
            type: 'post',
            dataType: 'json',
            success: function (rem) {
                if (rem.code == 200 || rem.status == 200) {
                    var c_citys = rem.data;
                    var html;
                    for (var i=0;i<c_citys.length;i++){
                        html +='<option value="'+c_citys[i]['merger_name']+'">'+c_citys[i]['name']+'</option>'
                    }
                    $('#city').html(html);
                } else {
                    layer.msg(rem.msg);
                }
            },
            error: function (err) {
                layer.msg('系统错误');
            }
        });

    });


</script>
</body>
</html>